package com.criticalbotch.ijnition;

//! Core class of the iJnition library

/*! iJnition is designed to help automate and streamline interaction with the Enjin API.
 * It does this by handling the parsing of the JSON output provided by the API and
 * providing pre-built classes to hold the information so retrieved.
 * 
 * The classes of note in this library are
 * <ul>
 * <li>iJnition (this class)</li>
 * <li>EnjinUser (holds the data of a single user)</li>
 * <li>EnjinTag (holds the data of a single tag)</li>
 * </ul>
 * 
 * There are other classes that may be of use, but the above are what you'll using non-stop.
 */
public class iJnition {

	private String baseURL; // ! Website URL, such as site.enjin.com

	private UserManager userManager;
	private TagManager tagManager;

	public iJnition(String website) {
		initialize(website);
	}

	public String getBaseURL() {
		return baseURL;
	}

	public EnjinUser getUser(int ID) {
		return userManager.getUser(ID);
	}

	public EnjinUser getUser(String name) {
		return userManager.getUser(name);
	}

	public EnjinTag getTag(int ID) {
		return tagManager.getTag(ID);
	}

	public EnjinTag getTag(String name) {
		return tagManager.getTag(name);
	}

	private void initialize(String website) {
		setBaseURL(website);
		userManager = new UserManager(this);
		tagManager = new TagManager(this);
	}

	public void setBaseURL(String baseURL) {
		if (baseURL.startsWith("http://"))
			this.baseURL = baseURL;
		else
			this.baseURL = "http://" + baseURL;
	}

	public void setTagManager(TagManager tagManager) {
		this.tagManager = tagManager;
	}

	public void setUserManager(UserManager userManager) {
		this.userManager = userManager;
	}

}
